package com.tcgroup.phone.base_core.loadsir;

import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.view.View;

import com.kingja.loadsir.callback.Callback;
import com.tcgroup.phone.base_core.R;

/**
 * 作者: wangfei
 * 创建时期: 2020/3/16.
 * 包名: com.tcgroup.phone.base_core.loadsir
 * 类名: HibeautyNew-Android
 */
public class LoadingTransCallback extends Callback {

    protected AnimationDrawable mAnimationDrawable;


    @Override
    protected int onCreateView() {
        return R.layout.core_trans_loading;
    }


    @Override
    protected void onViewCreate(Context context, View view) {
        super.onViewCreate(context, view);
//        ImageView imgLoading = view.findViewById(R.id.core_iv_loading);
//        mAnimationDrawable = (AnimationDrawable) imgLoading.getDrawable();
//        imgLoading.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
//            @Override
//            public void onSystemUiVisibilityChange(int visibility) {
//                KLog.i("TATTA","ss"+visibility);
//            }
//        });
//        loading(true);
    }

    public void startLoading(){
        if(null != mAnimationDrawable){
            mAnimationDrawable.start();
        }
    }
    public void stopLoading(){
        if(null != mAnimationDrawable) {
            mAnimationDrawable.stop();
        }
    }
    public void loading(boolean b){
        if(b){
            startLoading();
        }else{
            stopLoading();
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        //loading(false);
    }
}
